from flask import jsonify


class APIResponse:
    @staticmethod
    def success(data=None, message=None, status_code=200, headers=None):
        response = {
            'success': True,
            'data': data,
            'message': message,
            'status_code': status_code
        }
        return APIResponse._make_response(response, status_code, headers)

    @staticmethod
    def error(message, status_code=400, headers=None):
        response = {
            'success': False,
            'message': message,
            'status_code': status_code
        }
        return APIResponse._make_response(response, status_code, headers)

    @staticmethod
    def _make_response(response, status_code, headers):
        if headers is None:
            headers = {}
        headers['Content-Type'] = 'application/json'
        return jsonify(response), status_code, headers
